<template>
  <div>
    <template>
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>供应商投标</h3>
      </div>

      <el-table
          :data="sysUserData"
          border
          style="width: 100%">
        <el-table-column
            prop="username"
            label="供应商名称">
        </el-table-column>
        <el-table-column
            prop="type"
            label="商品类型">
        </el-table-column>
        <el-table-column
            prop="level"
            label="等级">
        </el-table-column>
        <el-table-column
            prop="name"
            label="负责人">
        </el-table-column>
        <el-table-column
            prop="phone"
            label="负责人电话">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="投标">
          <template slot-scope="scope">
            <el-button @click="bid(scope.row)" type="button" size="small">投标</el-button>
          </template>
        </el-table-column>
      </el-table>

      <div class="block">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[6, 8, 10, 12]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>

    </template>
  </div>
</template>


<script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Invitation",
  props:{
    usercodeTag:String,
    bmSerial:String,
    bmId:String
  },
  components:{

  },
  data(){
    return{
      pageNum: 1,
      pageSize: 6,
      total: '',
      sysUserData:[],
      dialogVisible: false
    }
  },
  mounted() {
    this.init(this.usercodeTag)
  },
  methods: {
    init(tag) {
      this.sysUserData = ''
      this.total = 1
      let url = '/csc/sys-user/selectSysUserByType/' + tag + '/' + this.pageNum + "/" + this.pageSize
      console.log(url)
      this.$axios.get(url).then(r => {
        console.log(r.data)
        this.sysUserData = r.data.records
        this.total = r.data.total
      })
    },
    bid(row) {
      console.log(row)
      this.$confirm('确定采购完成?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(row)
        let url = '/csc/invitation/bidMsg'
        let fd = new FormData
        fd.append("userid",row.userid)
        fd.append("usernumber",row.usernumber)
        fd.append("bmSerial",this.bmSerial)
        fd.append("bmId",this.bmId)
        this.$axios.post(url,fd).then(r=>{
          this.$message.success(r.data)
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.init()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.init()
    }
  }
}
</script>

<style scoped>

</style>